package com.bdqn.bookshop.controller.admin;

import com.bdqn.bookshop.entity.Garousel;
import com.bdqn.bookshop.service.GarouselService;
import com.bdqn.bookshop.utils.DataGridViewResult;
import com.bdqn.bookshop.utils.Result;
import com.bdqn.bookshop.vo.GarouselVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : 罗若然[LUO_RUO_RAN]
 * @date : 2020-07-28 20:23
 **/
@RestController
@RequestMapping("/admin/garousel")
public class AdminGarouselController {

    @Autowired
    private GarouselService garouselService;

    @RequestMapping("/garouselList")
    public DataGridViewResult garouselList(GarouselVo garouselVo){
            return garouselService.garouselList(garouselVo);
    }

    @PostMapping("/addGarousel")
    public Result addGarousel(@RequestParam(name="upload",required=false)MultipartFile file, Garousel garousel, HttpServletRequest request){
        return garouselService.addGarousel(file,garousel,request);
    }

    @PostMapping("/updateGarousel")
    public Result updateGarousel(@RequestParam(name="upload",required=false)MultipartFile file, Garousel garousel, HttpServletRequest request){
        return garouselService.updateGarousel(file,garousel,request);
    }

    @RequestMapping("/deleteById")
    public Result deleteById(Integer id,String imageUrl,HttpServletRequest request){
        return garouselService.deleteById(id,imageUrl,request);
    }

    @RequestMapping("/batchDelete")
    public Result batchDelete(String ids,String images,HttpServletRequest request){
        return  garouselService.batchDelete(ids,images,request);
    }

    @RequestMapping("/isSortCount")
    public Result isSortCount(Integer id,Integer sort){
        return garouselService.isSortCount(id,sort);
    }



}
